﻿
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration


Public Class Conexion
    Private oConexion As SqlConnection


    'Sub New(ByVal sCadConex As String)
    '    'oConexion = New SqlConnection(sCadConex)
    '    oConexion = New SqlConnection("CondorTravel")
    'End Sub

    Sub New(ByVal sCadConex As String)
        oConexion = New SqlConnection(sCadConex)
    End Sub

    Public ReadOnly Property Conexion() As SqlConnection
        Get
            Return oConexion
        End Get
    End Property

    Public ReadOnly Property BeginTransaction() As SqlTransaction
        Get
            If oConexion.State = ConnectionState.Open Then
                Return oConexion.BeginTransaction()
            Else
                Return Nothing
            End If
        End Get
    End Property

    Public Function Open() As String

        Try
            If oConexion.State <> ConnectionState.Open Then
                oConexion.Open()
            End If

            Return ""

        Catch ex As Exception
            Return ex.Message
        End Try

    End Function

    Public Sub Close()

        Try
            If oConexion.State = ConnectionState.Open Then
                oConexion.Close()
            End If

        Catch ex As Exception

        End Try

    End Sub

End Class
